import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueDevTools from 'vite-plugin-vue-devtools'
import monacoEditorPluginDefault from 'vite-plugin-monaco-editor'

const monacoEditorPlugin = (monacoEditorPluginDefault as any).default || monacoEditorPluginDefault

// https://vite.dev/config/
export default defineConfig({
  server: {
    // 服务器主机名，如果允许外部访问，可设置为 "0.0.0.0"
    host: "0.0.0.0",
    cors: true,
  },
  plugins: [
    vue(),
    vueDevTools(),
    monacoEditorPlugin({
      languageWorkers: ['editorWorkerService', 'typescript', 'json', 'html']
    })
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    },
  },
})
